***********ERROR - FACTOR VARIABLES NOT ALLOWED 

use "$data\analysisdata.dta", clear
log using "$results\Table3", replace
encode string_strata, generate(stratalottery)

* restrict sample
keep if ITTanalysis~=.
keep if round=="baseline"

foreach i in childageyears female birthorder {
bysort ITTanalysis: su `i' if endlinepresent==1 & `i'!=. 
regress `i' ITTanalysis i.strata if endlinepresent==1 &`i'!=., robust
 }
 
* Educational investments and outcomes

foreach i in educationyears admission_school Dabsentschool dropoffatschool askingforhomework Dtimespenthomework ///
womanhelphomework anyhelp {
bysort ITTanalysis: su `i' if endlinepresent==1 & `i'!=. & childageyears>=6 & childageyears<=16
regress `i' ITTanalysis i.strata if endlinepresent==1 &`i'!=. & childageyears>=6 & childageyears<=16 , robust
 }

* Health investments and outcomes
foreach i in Ddays_sick medicalhelp placeofmedicalhelp presence_woman_treatment {
bysort ITTanalysis: su `i' if endlinepresent==1 & `i'!=. & childageyears<=16
regress `i' ITTanalysis i.strata if endlinepresent==1 &`i'!=. & childageyears<=16 , robust
 } 
log close
exit
 